home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 09 / IndexOfDemo.java < prev    next >
Encoding:
Java Source  |  2000-09-08  |  757 b   |  16 lines

  1. class indexOfDemo {
  2. public static void main(String args[]) {
  3. String s = "Now is the time for all good men " +
  4.            "to come to the aid of their country " +
  5.            "and pay their due taxes.";
  6. System.out.println(s);
  7. System.out.println("indexOf(t) = " + s.indexOf("t"));
  8. System.out.println("lastIndexOf(t) = " + s.lastIndexOf("t"));
  9. System.out.println("indexOf(the) = " + s.indexOf("the"));
  10. System.out.println("lastIndexOf(the) = " + s.lastIndexOf("the"));
  11. System.out.println("indexOf(t, 10) = " + s.indexOf("t" , 10));
  12. System.out.println("lastIndexOf(t, 50) = " + s.lastIndexOf("t" , 50));
  13. System.out.println("indexOf(the, 10) = " + s.indexOf("the", 10));
  14. System.out.println("lastIndexOf(the, 50) = " + s.lastIndexOf("the", 50));
  15. } }
  16.